<html>
<head>
  <title>10-单表访问方法</title>
  <basefont face="微软雅黑" size="2" />
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  <meta name="exporter-version" content="YXBJ Windows/600646 (zh-CN, DDL); Windows/6.1.1 (Win64);"/>
  <meta name="content-class" content="yinxiang.markdown"/>
  <style>
    body, td {
      font-family: 微软雅黑;
      font-size: 10pt;
    }
  </style>
</head>
<body>
<a name="685"/>
<h1>10-单表访问方法</h1>

<div><span><div style="font-size: 14px; margin: 0; padding: 0; width: 100%;"><h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">1 访问方法（access method）</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">MySQL执行查询语句的方式称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">访问方法</strong>或者<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">访问类型</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">建表如下：<br/>
<img src="10-单表访问方法_files/1.png" type="image/png" data-filename="1.png"/></p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">const</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">通过<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">主键（聚簇索引）或唯一二级索引</strong>来定位一条记录的访问方法定义为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">const</strong>。<br/>
如果主键或者唯一索引是<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">多个列</strong>构成的话，索引中的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">每一个列都需要与常数进行等值比较</strong>，这个const访问方法才有效。<br/>
对于<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">唯一二级索引，查询列为NULL值的情况比较特殊</strong>，因为唯一二级索引并<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">不限制NULL值的数量</strong>，所以可能访问到多条记录，也就是说通过唯一二级索引NULL值时<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">不可以使用const方法</strong>来执行。</p>
<ol style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">通过<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">主键在聚簇索引中定位一条记录</strong>，比如：<br/>
SELECT * FROM single_table WHERE id = 1438；<br/>
<img src="10-单表访问方法_files/1.jpg" type="image/jpeg" data-filename="1.jpg"/></p>
</li>
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">根据<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">唯一二级索引列来定位一条记录</strong>：<br/>
SELECT * FROM single_table WHERE key2 = 3841；<br/>
<img src="10-单表访问方法_files/1 [1].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
</li>
</ol>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">ref</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">搜索条件为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">二级索引列</strong>与<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">常数等值比较</strong>的访问方法称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">ref</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">对某个普通的二级索引列与常数进行等值比较：<br/>
<img src="10-单表访问方法_files/1 [2].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">二级索引列值为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">NULL</strong>的情况：<br/>
不论是普通的二级索引，还是唯一二级索引，它们的索引列对包含NULL值的数量并不限制，所以我们采用key IS NULL这种形式的搜索条件最多只能使用ref的访问方法，而不是const的访问方法。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">对于某个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">包含多个索引列的二级索引</strong>来说，只要是<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">最左边的连续索引列是与常数的等值比较</strong>就可能采用ref的访问方法，比方说下边这几个查询：<br/>
SELECT * FROM single_table WHERE key_part1 = 'god like'；<br/>
SELECT * FROM single_table WHERE key_part1 = 'god like' AND key_part2 = 'legendary'；<br/>
SELECT * FROM single_table WHERE key_part1 = 'god like' AND key_part2 = 'legendary' AND key_part3 = 'penta kill';<br/>
但是如果最左边的连续索引列并不全部是等值比较的话，它的访问方法就不能称为ref了，比方说这样：<br/>
SELECT * FROM single_table WHERE key_part1 = 'god like' AND key_part2 &gt; 'legendary'；</p>
</li>
</ul>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">ref_or_null</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">不仅想找出某个二级索引列的值等于某个常数的记录，还想把该列的值为NULL的记录也找出来：<br/>
SELECT * FROM single_demo WHERE key1 = 'abc' OR key1 IS NULL；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">当使用二级索引而不是全表扫描的方式执行该查询时，这种类型的查询使用的访问方法就称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">ref_or_null</strong>，这个ref_or_null访问方法的执行过程如下：<img src="10-单表访问方法_files/1 [3].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">range</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">利用索引（包含聚簇索引和二级索引）进行<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">范围匹配</strong>的访问方法称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">range</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">例如：<br/>
SELECT * FROM single_table WHERE key2 IN (1438, 6328) OR (key2 &gt;= 38 AND key2 &lt;= 79)；</p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">index</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">通过<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">遍历二级索引直接返回数据（不需要回表）<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">的执行方式称为</strong>index</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">例如：<br/>
SELECT key_part1, key_part2, key_part3 FROM single_table WHERE key_part2 = 'abc'；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">由于key_part2并不是联合索引idx_key_part最左索引列，所以我们无法使用ref或者range访问方法来执行这个语句。但是这个查询符合下边这两个条件：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">它的查询列表只有3个列：key_part1, key_part2, key_part3，而索引idx_key_part又包含这三个列；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">搜索条件中只有key_part2列。这个列也包含在索引idx_key_part中；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">也就是说我们可以直接通过遍历idx_key_part索引的叶子节点的记录来比较key_part2 = 'abc'这个条件是否成立，把匹配成功的二级索引记录的key_part1, key_part2, key_part3列的值直接加到结果集中就行了。由于<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">二级索引记录比聚簇索记录小的多</strong>（聚簇索引记录要存储所有用户定义的列以及所谓的隐藏列，而二级索引记录只需要存放索引列和主键），<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">而且这个过程也不用进行回表操作</strong>，所以直接遍历二级索引比直接遍历聚簇索引的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">成本要小很多</strong>，设计MySQL的大叔就把这种采用遍历二级索引记录的执行方式称之为：index。</p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">all</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">使用全表扫描执行查询的方式称为all。</p>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">2 二级索引+回表</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">一般情况下</strong>，一个select语句只能使用一个索引执行查询，比如：</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">SELECT * FROM single_table WHERE key1 = 'abc' AND key2 &gt; 1000；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">查询优化器会识别到两个搜索条件：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">key1 = 'abd'</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">key2 &gt; 1000</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">优化器一般会根据single_table表的统计数据来判断到底使用哪个条件到对应的二级索引中查询扫描的行数会更少，选择那个扫描行数较少的条件到对应的二级索引中查询（关于如何比较的细节我们后边的章节中会唠叨）。然后将从该二级索引中查询到的结果经过回表得到完整的用户记录后再根据其余的WHERE条件过滤记录。一般来说，等值查找比范围查找需要扫描的行数更少（也就是ref的访问方法一般比range好，但这也不总是一定的，也可能采用ref访问方法的那个索引列的值为特定值的行数特别多），所以这里假设优化器决定使用idx_key1索引进行查询，那么整个查询过程可以分为两个步骤：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">使用二级索引定位记录的阶段，也就是根据条件key1 = 'abc'从idx_key1索引代表的B+树中找到对应的二级索引记录；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">回表阶段，也就是根据上一步骤中找到的记录的主键值进行回表操作，也就是到聚簇索引中找到对应的完整的用户记录，再根据条件key2 &gt; 1000到完整的用户记录继续过滤。将最终符合过滤条件的记录返回给用户；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">因为二级索引的节点中的记录只包含索引列和主键，所以在步骤1中使用idx_key1索引进行查询时只会用到与key1列有关的搜索条件，其余条件，比如key2 &gt; 1000这个条件在步骤1中是用不到的，只有在步骤2完成回表操作后才能继续针对完整的用户记录中继续过滤。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">注意：<br/>
一般情况下执行一个查询只会用到单个二级索引，不过还是有特殊情况的。</p>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">3 明确range访问方法使用的范围区间</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">在日常的工作中，一个查询的WHERE子句可能有很多个小的搜索条件，这些搜索条件需要使用AND或者OR操作符连接起来：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">cond1 AND cond2</strong> ：只有当cond1和cond2都为TRUE时整个表达式才为TRUE；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">cond1 OR cond2</strong>：只要cond1或者cond2中有一个为TRUE整个表达式就为TRUE；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">当我们想使用range访问方法来执行一个查询语句时，重点就是找出该查询可用的索引以及这些索引对应的范围区间。下边分两种情况看一下怎么从由AND或OR组成的复杂搜索条件中提取出正确的范围区间。</p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">3-1 所有搜索条件都可以使用某个索引的情况</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">SELECT * FROM single_table WHERE key2 &gt; 100 AND key2 &gt; 200；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">SELECT * FROM single_table WHERE key2 &gt; 100 OR key2 &gt; 200；<br/>
以上2个查询中，所有的查询条件都可以用到同一索引。</p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">3-2 有的搜索条件无法使用索引的情况</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">在为某个索引确定范围区间的时候只需要把用不到相关索引的搜索条件替换为TRUE就好了。</strong><br/>
之所以把用不到索引的搜索条件替换为TRUE，是因为我们不打算使用这些条件进行在该索引上进行过滤，所以不管索引的记录满不满足这些条件，我们都把它们选取出来，待到之后回表的时候再使用它们过滤。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">使用and的情况</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">SELECT * FROM single_table WHERE key2 &gt; 100 AND common_field = 'abc'；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">简化后就是：<br/>
SELECT * FROM single_table WHERE key2 &gt; 100；<br/>
那么这个查询就可以先使用key2二级索引，再进行回表，然后根据common_field = 'abc'过滤出所需结果集即可。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">使用or的情况</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">SELECT * FROM single_table WHERE key2 &gt; 100 OR common_field = 'abc'；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">简化后是：<br/>
SELECT * FROM single_table WHERE TRUE；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">也就是说如果强制使用idx_key2执行查询的话，对应的范围区间就是(-∞, +∞)，也就是需要<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">将全部二级索引的记录进行回表</strong>，这个代价肯定比直接全表扫描都大了。也就是说<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">一个使用到索引的搜索条件和没有使用该索引的搜索条件使用OR连接起来后是无法使用该索引的。</strong></p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">3-3 复杂搜索条件下找出范围匹配的区间</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">比如：<br/>
<img src="10-单表访问方法_files/Image.png" type="image/png" data-filename="Image.png"/></p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">首先查看<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">WHERE子句</strong>中的搜索条件都涉及到了哪些列，<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">哪些列可能使用到索引</strong><br/>
这个查询的搜索条件涉及到了key1、key2、common_field这3个列，然后key1列有普通的二级索引idx_key1，key2列有唯一二级索引idx_key2。</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">对于那些可能用到的索引，分析它们的范围区间</strong></li>
</ul>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">4 索引合并</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">MySQL在一般情况下执行一个查询时最多只会用到单个二级索引，但是在某些特殊情况下也可能在一个查询中使用到多个二级索引，这种使用到多个索引来完成一次查询的执行方法称为：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Index Merge</strong>。具体的索引合并算法有以下三种：</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">Intersection合并（交集合并）</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">Intersection翻译过来的意思是交集。这里是说某个查询可以使用多个二级索引，将从多个二级索引中查询到的结果取交集，比方说下边这个查询：</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">SELECT * FROM single_table WHERE key1 = 'a' AND key3 = 'b'；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">假设这个查询使用Intersection合并的方式执行的话，那这个过程就是这样的：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">从idx_key1二级索引对应的B+树中取出key1 = 'a'的相关记录；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">从idx_key3二级索引对应的B+树中取出key3 = 'b'的相关记录；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">二级索引的记录都是由索引列 + 主键构成的，所以我们可以计算出这两个结果集中id值的交集；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">按照上一步生成的id值列表进行回表操作，也就是从聚簇索引中把指定id值的完整用户记录取出来，返回给用户。</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">为啥不直接使用idx_key1或者idx_key3只根据某个搜索条件去读取一个二级索引，然后回表后再过滤另外一个搜索条件呢？这里要分析一下两种查询执行方式之间需要的成本代价。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">只读取一个二级索引的成本：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">按照某个搜索条件读取一个二级索引</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">根据从该二级索引得到的主键值进行回表操作，然后再过滤其他的搜索条件</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">读取多个二级索引之后取交集成本：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">按照不同的搜索条件分别读取不同的二级索引</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">将从多个二级索引得到的主键值取交集，然后进行回表操作</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">虽然读取多个二级索引比读取一个二级索引消耗性能，但是读取二级索引的操作是顺序I/O，而回表操作是随机I/O，所以如果只读取一个二级索引时需要回表的记录数特别多，而读取多个二级索引之后取交集的记录数非常少，当节省的因为回表而造成的性能损耗比访问多个二级索引带来的性能损耗更高时，读取多个二级索引后取交集比只读取一个二级索引的成本更低。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">MySQL在某些特定的情况下才可能会使用到Intersection索引合并：</strong></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">情况一</strong>：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">二级索引列是等值匹配的情况</strong>，对于联合索引来说，在联合索引中的每个列都必须等值匹配，不能出现只出现匹配部分列的情况。<img src="10-单表访问方法_files/1 [1].png" type="image/png" data-filename="1.png"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">情况二</strong>：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">主键列可以是范围匹配</strong><br/>
<img src="10-单表访问方法_files/Image [1].png" type="image/png" data-filename="Image.png"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">对于InnoDB的二级索引来说，记录先是按照索引列进行排序，如果该二级索引是一个联合索引，那么会按照联合索引中的各个列依次排序。而二级索引的用户记录是由索引列 + 主键构成的，二级索引列的值相同的记录可能会有好多条，这些索引列的值相同的记录又是按照主键的值进行排序的。所以重点来了，之所以在二级索引列都是等值匹配的情况下才可能使用Intersection索引合并，是因为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">只有在这种情况下根据二级索引查询出的结果集是按照主键值排序的</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">Intersection索引合并会把从多个二级索引中查询出的主键值求交集，如果从各个二级索引中查询的到的结果集本身就是已经按照主键排好序的，那么求交集的过程就很easy啦。假设某个查询使用Intersection索引合并的方式从idx_key1和idx_key2这两个二级索引中获取到的主键值分别是：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">从idx_key1中获取到已经排好序的主键值：1、3、5；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">从idx_key2中获取到已经排好序的主键值：2、3、4；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">那么求交集的过程就是这样：逐个取出这两个结果集中最小的主键值，如果两个值相等，则加入最后的交集结果中，否则丢弃当前较小的主键值，再取该丢弃的主键值所在结果集的后一个主键值来比较，直到某个结果集中的主键值用完了：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">先取出这两个结果集中较小的主键值做比较，因为1 &lt; 2，所以把idx_key1的结果集的主键值1丢弃，取出后边的3来比较；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">因为3 &gt; 2，所以把idx_key2的结果集的主键值2丢弃，取出后边的3来比较；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">因为3 = 3，所以把3加入到最后的交集结果中，继续两个结果集后边的主键值来比较；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">后边的主键值也不相等，所以最后的交集结果中只包含主键值3；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">这个过程其实可快了，时间复杂度是O(n)，但是如果从各个二级索引中查询出的结果集并不是按照主键排序的话，那就要先把结果集中的主键值排序完再来做上边的那个过程，就比较耗时了。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">按照有序的主键值去回表取记录有个专有名词儿，叫：Rowid Ordered Retrieval，简称ROR。</strong></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">另外，不仅是多个二级索引之间可以采用Intersection索引合并，索引合并也可以有聚簇索引参加，也就是我们上边写的情况二：在搜索条件中有主键的范围匹配的情况下也可以使用Intersection索引合并索引合并。为啥主键这就可以范围匹配了？还是得回到应用场景里，比如看下边这个查询：<br/>
SELECT * FROM single_table WHERE key1 = 'a' AND id &gt; 100；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">假设这个查询可以采用Intersection索引合并，我们理所当然的以为这个查询会分别按照id &gt; 100这个条件从聚簇索引中获取一些记录，在通过key1 = 'a'这个条件从idx_key1二级索引中获取一些记录，然后再求交集，其实这样就把问题复杂化了，没必要从聚簇索引中获取一次记录。别忘了二级索引的记录中都带有主键值的，所以可以在从idx_key1中获取到的主键值上直接运用条件id &gt; 100过滤就行了，这样多简单。所以涉及主键的搜索条件只不过是为了从别的二级索引得到的结果集中过滤记录罢了，是不是等值匹配不重要。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">当然，上边说的情况一和情况二只是发生Intersection索引合并的必要条件，不是充分条件。也就是说即使情况一、情况二成立，也不一定发生Intersection索引合并，这得看优化器的心情。优化器只有在单独根据搜索条件从某个二级索引中获取的记录数太多，导致回表开销太大，而通过Intersection索引合并后需要回表的记录数大大减少时才会使用Intersection索引合并。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">Union合并</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">Intersection是交集的意思，这适用于使用不同索引的搜索条件之间使用AND连接起来的情况；Union是并集的意思，适用于使用不同索引的搜索条件之间使用OR连接起来的情况。与Intersection索引合并类似，MySQL在某些特定的情况下才可能会使用到Union索引合并：</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">情况一</strong>：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">二级索引列是等值匹配的情况，对于联合索引来说，在联合索引中的每个列都必须等值匹配，不能出现只出现匹配部分列的情况。</strong><br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">情况二</strong>：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">主键列可以是范围匹配。</strong><br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">情况三</strong>：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">使用Intersection索引合并的搜索条件。</strong><br/>
这种情况其实也挺好理解，就是搜索条件的某些部分使用Intersection索引合并的方式得到的主键集合和其他方式得到的主键集合取交集，比方说这个查询：<br/>
SELECT * FROM single_table WHERE key_part1 = 'a' AND key_part2 = 'b' AND key_part3 = 'c' OR (key1 = 'a' AND key3 = 'b')；</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">Sort-Union合并</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">Union索引合并的使用条件太苛刻，必须保证各个二级索引列在进行等值匹配的条件下才可能被用到，比方说下边这个查询就无法使用到Union索引合并：<br/>
SELECT * FROM single_table WHERE key1 &lt; 'a' OR key3 &gt; 'z'；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">这是因为根据key1 &lt; 'a'从idx_key1索引中获取的二级索引记录的主键值不是排好序的，根据key3 &gt; 'z'从idx_key3索引中获取的二级索引记录的主键值也不是排好序的，但是key1 &lt; 'a'和key3 &gt; 'z'这两个条件又特别让我们动心，所以我们可以这样：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">先根据key1 &lt; 'a'条件从idx_key1二级索引总获取记录，并按照记录的主键值进行排序；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">再根据key3 &gt; 'z'条件从idx_key3二级索引总获取记录，并按照记录的主键值进行排序；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">因为上述的两个二级索引主键值都是排好序的，剩下的操作和Union索引合并方式就一样了；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">我们把上述这种先按照二级索引记录的主键值进行排序，之后按照Union索引合并方式执行的方式称之为Sort-Union索引合并，很显然，这种Sort-Union索引合并比单纯的Union索引合并多了一步对二级索引记录的主键值排序的过程。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">为啥有Sort-Union索引合并，就没有Sort-Intersection索引合并么？是的，的确没有Sort-Intersection索引合并这么一说， Sort-Union的适用场景是单独根据搜索条件从某个二级索引中获取的记录数比较少，这样即使对这些二级索引记录按照主键值进行排序的成本也不会太高 而Intersection索引合并的适用场景是单独根据搜索条件从某个二级索引中获取的记录数太多，导致回表开销太大，合并后可以明显降低回表开销，但是如果加入Sort-Intersection后，就需要为大量的二级索引记录按照主键值进行排序，这个成本可能比回表查询都高了，所以也就没有引入Sort-Intersection这个玩意儿。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">如果能用联合索引最好用联合索引代替索引合并。</p>
</div><center style="display:none !important;visibility:collapse !important;height:0 !important;white-space:nowrap;width:100%;overflow:hidden">%23%23%201%20%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%EF%BC%88access%20method%EF%BC%89%0AMySQL%E6%89%A7%E8%A1%8C%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5%E7%9A%84%E6%96%B9%E5%BC%8F%E7%A7%B0%E4%B9%8B%E4%B8%BA**%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95**%E6%88%96%E8%80%85**%E8%AE%BF%E9%97%AE%E7%B1%BB%E5%9E%8B**%E3%80%82%0A%0A%0A%E5%BB%BA%E8%A1%A8%E5%A6%82%E4%B8%8B%EF%BC%9A%0A!%5B61b7d358d79e40ed187b32667e2ae053.png%5D(en-resource%3A%2F%2Fdatabase%2F742%3A1)%0A%0A%23%23%23%20const%0A%0A%E9%80%9A%E8%BF%87**%E4%B8%BB%E9%94%AE%EF%BC%88%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%EF%BC%89%E6%88%96%E5%94%AF%E4%B8%80%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95**%E6%9D%A5%E5%AE%9A%E4%BD%8D%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E7%9A%84%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%E5%AE%9A%E4%B9%89%E4%B8%BA**const**%E3%80%82%0A%E5%A6%82%E6%9E%9C%E4%B8%BB%E9%94%AE%E6%88%96%E8%80%85%E5%94%AF%E4%B8%80%E7%B4%A2%E5%BC%95%E6%98%AF**%E5%A4%9A%E4%B8%AA%E5%88%97**%E6%9E%84%E6%88%90%E7%9A%84%E8%AF%9D%EF%BC%8C%E7%B4%A2%E5%BC%95%E4%B8%AD%E7%9A%84**%E6%AF%8F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95**%EF%BC%8C%E6%AF%94%E5%A6%82%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20id%20%3D%201438%EF%BC%9B%0A!%5B99a1fffe8d0d7dbe9e121dc36d7bb2bc.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F744%3A1)%0A%0A2.%20%E6%A0%B9%E6%8D%AE**%E5%94%AF%E4%B8%80%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E5%88%97%E6%9D%A5%E5%AE%9A%E4%BD%8D%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95**%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key2%20%3D%203841%EF%BC%9B%0A!%5Bad0b109e8d677d3e6e0e74e4e550cb94.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F746%3A1)%0A%0A%23%23%23%20ref%0A%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E4%B8%BA**%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E5%88%97**%E4%B8%8E**%E5%B8%B8%E6%95%B0%E7%AD%89%E5%80%BC%E6%AF%94%E8%BE%83**%E7%9A%84%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%E7%A7%B0%E4%B8%BA**ref**%E3%80%82%0A%0A%E5%AF%B9%E6%9F%90%E4%B8%AA%E6%99%AE%E9%80%9A%E7%9A%84%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E5%88%97%E4%B8%8E%E5%B8%B8%E6%95%B0%E8%BF%9B%E8%A1%8C%E7%AD%89%E5%80%BC%E6%AF%94%E8%BE%83%EF%BC%9A%0A!%5Bcd6f5433f9d4437aa34ead8ac058ea64.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F748%3A1)%0A%0A*%20%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E5%88%97%E5%80%BC%E4%B8%BA**NULL**%E7%9A%84%E6%83%85%E5%86%B5%EF%BC%9A%0A%E4%B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E7%9A%84%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%EF%BC%8C%E6%AF%94%E6%96%B9%E8%AF%B4%E4%B8%8B%E8%BE%B9%E8%BF%99%E5%87%A0%E4%B8%AA%E6%9F%A5%E8%AF%A2%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key_part1%20%3D%20'god%20like'%EF%BC%9B%0ASELECT%20*%20FROM%20single_table%20WHERE%20key_part1%20%3D%20'god%20like'%20AND%20key_part2%20%3D%20'legendary'%EF%BC%9B%0ASELECT%20*%20FROM%20single_table%20WHERE%20key_part1%20%3D%20'god%20like'%20AND%20key_part2%20%3D%20'legendary'%20AND%20key_part3%20%3D%20'penta%20kill'%3B%0A%E4%BD%86%E6%98%AF%E5%A6%82%E6%9E%9C%E6%9C%80%E5%B7%A6%E8%BE%B9%E7%9A%84%E8%BF%9E%E7%BB%AD%E7%B4%A2%E5%BC%95%E5%88%97%E5%B9%B6%E4%B8%8D%E5%85%A8%E9%83%A8%E6%98%AF%E7%AD%89%E5%80%BC%E6%AF%94%E8%BE%83%E7%9A%84%E8%AF%9D%EF%BC%8C%E5%AE%83%E7%9A%84%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%E5%B0%B1%E4%B8%8D%E8%83%BD%E7%A7%B0%E4%B8%BAref%E4%BA%86%EF%BC%8C%E6%AF%94%E6%96%B9%E8%AF%B4%E8%BF%99%E6%A0%B7%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key_part1%20%3D%20'god%20like'%20AND%20key_part2%20%3E%20'legendary'%EF%BC%9B%0A%0A%23%23%23%20ref_or_null%0A%0A%E4%B8%8D%E4%BB%85%E6%83%B3%E6%89%BE%E5%87%BA%E6%9F%90%E4%B8%AA%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E5%88%97%E7%9A%84%E5%80%BC%E7%AD%89%E4%BA%8E%E6%9F%90%E4%B8%AA%E5%B8%B8%E6%95%B0%E7%9A%84%E8%AE%B0%E5%BD%95%EF%BC%8C%E8%BF%98%E6%83%B3%E6%8A%8A%E8%AF%A5%E5%88%97%E7%9A%84%E5%80%BC%E4%B8%BANULL%E7%9A%84%E8%AE%B0%E5%BD%95%E4%B9%9F%E6%89%BE%E5%87%BA%E6%9D%A5%EF%BC%9A%0ASELECT%20*%20FROM%20single_demo%20WHERE%20key1%20%3D%20'abc'%20OR%20key1%20IS%20NULL%EF%BC%9B%0A%0A%E5%BD%93%E4%BD%BF%E7%94%A8%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E8%80%8C%E4%B8%8D%E6%98%AF%E5%85%A8%E8%A1%A8%E6%89%AB%E6%8F%8F%E7%9A%84%E6%96%B9%E5%BC%8F%E6%89%A7%E8%A1%8C%E8%AF%A5%E6%9F%A5%E8%AF%A2%E6%97%B6%EF%BC%8C%E8%BF%99%E7%A7%8D%E7%B1%BB%E5%9E%8B%E7%9A%84%E6%9F%A5%E8%AF%A2%E4%BD%BF%E7%94%A8%E7%9A%84%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%E5%B0%B1%E7%A7%B0%E4%B8%BA**ref_or_null**%EF%BC%8C%E8%BF%99%E4%B8%AAref_or_null%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%E7%9A%84%E6%89%A7%E8%A1%8C%E8%BF%87%E7%A8%8B%E5%A6%82%E4%B8%8B%EF%BC%9A!%5B64de641bcbc6c808c65ba559bc45bafa.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F750%3A1)%0A%0A%23%23%23%20range%0A%E5%88%A9%E7%94%A8%E7%B4%A2%E5%BC%95%EF%BC%88%E5%8C%85%E5%90%AB%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E5%92%8C%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%EF%BC%89%E8%BF%9B%E8%A1%8C**%E8%8C%83%E5%9B%B4%E5%8C%B9%E9%85%8D**%E7%9A%84%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%E7%A7%B0%E4%B8%BA**range**%E3%80%82%0A%0A%E4%BE%8B%E5%A6%82%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key2%20IN%20(1438%2C%206328)%20OR%20(key2%20%3E%3D%2038%20AND%20key2%20%3C%3D%2079)%EF%BC%9B%0A%0A%23%23%23%20index%0A%E9%80%9A%E8%BF%87**%E9%81%8D%E5%8E%86%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E7%9B%B4%E6%8E%A5%E8%BF%94%E5%9B%9E%E6%95%B0%E6%8D%AE%EF%BC%88%E4%B8%8D%E9%9C%80%E8%A6%81%E5%9B%9E%E8%A1%A8%EF%BC%89**%E7%9A%84%E6%89%A7%E8%A1%8C%E6%96%B9%E5%BC%8F%E7%A7%B0%E4%B8%BA**index**%E3%80%82%0A%0A%E4%BE%8B%E5%A6%82%EF%BC%9A%0ASELECT%20key_part1%2C%20key_part2%2C%20key_part3%20FROM%20single_table%20WHERE%20key_part2%20%3D%20'abc'%EF%BC%9B%0A%0A%E7%94%B1%E4%BA%8Ekey_part2%E5%B9%B6%E4%B8%8D%E6%98%AF%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95idx_key_part%E6%9C%80%E5%B7%A6%E7%B4%A2%E5%BC%95%E5%88%97%EF%BC%8C%E6%89%80%E4%BB%A5%E6%88%91%E4%BB%AC%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8ref%E6%88%96%E8%80%85range%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%E6%9D%A5%E6%89%A7%E8%A1%8C%E8%BF%99%E4%B8%AA%E8%AF%AD%E5%8F%A5%E3%80%82%E4%BD%86%E6%98%AF%E8%BF%99%E4%B8%AA%E6%9F%A5%E8%AF%A2%E7%AC%A6%E5%90%88%E4%B8%8B%E8%BE%B9%E8%BF%99%E4%B8%A4%E4%B8%AA%E6%9D%A1%E4%BB%B6%EF%BC%9A%0A%0A*%20%E5%AE%83%E7%9A%84%E6%9F%A5%E8%AF%A2%E5%88%97%E8%A1%A8%E5%8F%AA%E6%9C%893%E4%B8%AA%E5%88%97%EF%BC%9Akey_part1%2C%C2%A0key_part2%2C%C2%A0key_part3%EF%BC%8C%E8%80%8C%E7%B4%A2%E5%BC%95idx_key_part%E5%8F%88%E5%8C%85%E5%90%AB%E8%BF%99%E4%B8%89%E4%B8%AA%E5%88%97%EF%BC%9B%0A*%20%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E4%B8%AD%E5%8F%AA%E6%9C%89key_part2%E5%88%97%E3%80%82%E8%BF%99%E4%B8%AA%E5%88%97%E4%B9%9F%E5%8C%85%E5%90%AB%E5%9C%A8%E7%B4%A2%E5%BC%95idx_key_part%E4%B8%AD%EF%BC%9B%0A%0A%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%AF%B4%E6%88%91%E4%BB%AC%E5%8F%AF%E4%BB%A5%E7%9B%B4%E6%8E%A5%E9%80%9A%E8%BF%87%E9%81%8D%E5%8E%86idx_key_part%E7%B4%A2%E5%BC%95%E7%9A%84%E5%8F%B6%E5%AD%90%E8%8A%82%E7%82%B9%E7%9A%84%E8%AE%B0%E5%BD%95%E6%9D%A5%E6%AF%94%E8%BE%83key_part2%20%3D%20'abc'%E8%BF%99%E4%B8%AA%E6%9D%A1%E4%BB%B6%E6%98%AF%E5%90%A6%E6%88%90%E7%AB%8B%EF%BC%8C%E6%8A%8A%E5%8C%B9%E9%85%8D%E6%88%90%E5%8A%9F%E7%9A%84%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E8%AE%B0%E5%BD%95%E7%9A%84key_part1%2C%C2%A0key_part2%2C%C2%A0key_part3%E5%88%97%E7%9A%84%E5%80%BC%E7%9B%B4%E6%8E%A5%E5%8A%A0%E5%88%B0%E7%BB%93%E6%9E%9C%E9%9B%86%E4%B8%AD%E5%B0%B1%E8%A1%8C%E4%BA%86%E3%80%82%E7%94%B1%E4%BA%8E**%E4%BA%8C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8%AE%B0%E5%BD%95%E7%9A%84%E6%89%A7%E8%A1%8C%E6%96%B9%E5%BC%8F%E7%A7%B0%E4%B9%8B%E4%B8%BA%EF%BC%9Aindex%E3%80%82%0A%0A%23%23%23%20all%0A%E4%BD%BF%E7%94%A8%E5%85%A8%E8%A1%A8%E6%89%AB%E6%8F%8F%E6%89%A7%E8%A1%8C%E6%9F%A5%E8%AF%A2%E7%9A%84%E6%96%B9%E5%BC%8F%E7%A7%B0%E4%B8%BAall%E3%80%82%0A%0A%23%23%202%20%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%2B%E5%9B%9E%E8%A1%A8%0A**%E4%B8%80%E8%88%AC%E6%83%85%E5%86%B5%E4%B8%8B**%EF%BC%8C%E4%B8%80%E4%B8%AAselect%E8%AF%AD%E5%8F%A5%E5%8F%AA%E8%83%BD%E4%BD%BF%E7%94%A8%E4%B8%80%E4%B8%AA%E7%B4%A2%E5%BC%95%E6%89%A7%E8%A1%8C%E6%9F%A5%E8%AF%A2%EF%BC%8C%E6%AF%94%E5%A6%82%EF%BC%9A%0A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key1%20%3D%20'abc'%20AND%20key2%20%3E%201000%EF%BC%9B%0A%0A%E6%9F%A5%E8%AF%A2%E4%BC%98%E5%8C%96%E5%99%A8%E4%BC%9A%E8%AF%86%E5%88%AB%E5%88%B0%E4%B8%A4%E4%B8%AA%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%EF%BC%9A%0A%0A*%20key1%20%3D%20'abd'%0A*%20key2%20%3E%201000%0A%0A%0A%E4%BC%98%E5%8C%96%E5%99%A8%E4%B8%80%E8%88%AC%E4%BC%9A%E6%A0%B9%E6%8D%AEsingle_table%E8%A1%A8%E7%9A%84%E7%BB%9F%E8%AE%A1%E6%95%B0%E6%8D%AE%E6%9D%A5%E5%88%A4%E6%96%AD%E5%88%B0%E5%BA%95%E4%BD%BF%E7%94%A8%E5%93%AA%E4%B8%AA%E6%9D%A1%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%E6%95%B4%E4%B8%AA%E8%A1%A8%E8%BE%BE%E5%BC%8F%E5%B0%B1%E4%B8%BATRUE%EF%BC%9B%0A%0A%E5%BD%93%E6%88%91%E4%BB%AC%E6%83%B3%E4%BD%BF%E7%94%A8range%E8%AE%BF%E9%97%AE%E6%96%B9%E6%B3%95%E6%9D%A5%E6%89%A7%E8%A1%8C%E4%B8%80%E4%B8%AA%E6%9F%A5%E8%AF%A2%E8%AF%AD%E5%8F%A5%E6%97%B6%EF%BC%8C%E9%87%8D%E7%82%B9%E5%B0%B1%E6%98%AF%E6%89%BE%E5%87%BA%E8%AF%A5%E6%9F%A5%E8%AF%A2%E5%8F%AF%E7%94%A8%E7%9A%84%E7%B4%A2%E5%BC%95%E4%BB%A5%E5%8F%8A%E8%BF%99%E4%BA%9B%E7%B4%A2%E5%BC%95%E5%AF%B9%E5%BA%94%E7%9A%84%E8%8C%83%E5%9B%B4%E5%8C%BA%E9%97%B4%E3%80%82%E4%B8%8B%E8%BE%B9%E5%88%86%E4%B8%A4%E7%A7%8D%E6%83%85%E5%86%B5%E7%9C%8B%E4%B8%80%E4%B8%8B%E6%80%8E%E4%B9%88%E4%BB%8E%E7%94%B1AND%E6%88%96OR%E7%BB%84%E6%88%90%E7%9A%84%E5%A4%8D%E6%9D%82%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E4%B8%AD%E6%8F%90%E5%8F%96%E5%87%BA%E6%AD%A3%E7%A1%AE%E7%9A%84%E8%8C%83%E5%9B%B4%E5%8C%BA%E9%97%B4%E3%80%82%0A%0A%23%23%23%203-1%20%E6%89%80%E6%9C%89%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E9%83%BD%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E6%9F%90%E4%B8%AA%E7%B4%A2%E5%BC%95%E7%9A%84%E6%83%85%E5%86%B5%0A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key2%20%3E%20100%20AND%20key2%20%3E%20200%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1%E4%BB%B6%E8%BF%9B%E8%A1%8C%E5%9C%A8%E8%AF%A5%E7%B4%A2%E5%BC%95%E4%B8%8A%E8%BF%9B%E8%A1%8C%E8%BF%87%E6%BB%A4%EF%BC%8C%E6%89%80%E4%BB%A5%E4%B8%8D%E7%AE%A1%E7%B4%A2%E5%BC%95%E7%9A%84%E8%AE%B0%E5%BD%95%E6%BB%A1%E4%B8%8D%E6%BB%A1%E8%B6%B3%E8%BF%99%E4%BA%9B%E6%9D%A1%E4%BB%B6%EF%BC%8C%E6%88%91%E4%BB%AC%E9%83%BD%E6%8A%8A%E5%AE%83%E4%BB%AC%E9%80%89%E5%8F%96%E5%87%BA%E6%9D%A5%EF%BC%8C%E5%BE%85%E5%88%B0%E4%B9%8B%E5%90%8E%E5%9B%9E%E8%A1%A8%E7%9A%84%E6%97%B6%E5%80%99%E5%86%8D%E4%BD%BF%E7%94%A8%E5%AE%83%E4%BB%AC%E8%BF%87%E6%BB%A4%E3%80%82%0A%0A%23%23%23%23%20%E4%BD%BF%E7%94%A8and%E7%9A%84%E6%83%85%E5%86%B5%0A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key2%20%3E%20100%20AND%20common_field%20%3D%20'abc'%EF%BC%9B%0A%0A%E7%AE%80%E5%8C%96%E5%90%8E%E5%B0%B1%E6%98%AF%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key2%20%3E%20100%EF%BC%9B%0A%E9%82%A3%E4%B9%88%E8%BF%99%E4%B8%AA%E6%9F%A5%E8%AF%A2%E5%B0%B1%E5%8F%AF%E4%BB%A5%E5%85%88%E4%BD%BF%E7%94%A8key2%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%EF%BC%8C%E5%86%8D%E8%BF%9B%E8%A1%8C%E5%9B%9E%E8%A1%A8%EF%BC%8C%E7%84%B6%E5%90%8E%E6%A0%B9%E6%8D%AEcommon_field%20%3D%20'abc'%E8%BF%87%E6%BB%A4%E5%87%BA%E6%89%80%E9%9C%80%E7%BB%93%E6%9E%9C%E9%9B%86%E5%8D%B3%E5%8F%AF%E3%80%82%0A%0A%23%23%23%23%20%E4%BD%BF%E7%94%A8or%E7%9A%84%E6%83%85%E5%86%B5%0A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key2%20%3E%20100%20OR%20common_field%20%3D%20'abc'%EF%BC%9B%0A%0A%E7%AE%80%E5%8C%96%E5%90%8E%E6%98%AF%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20TRUE%EF%BC%9B%0A%0A%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%AF%B4%E5%A6%82%E6%9E%9C%E5%BC%BA%E5%88%B6%E4%BD%BF%E7%94%A8idx_key2%E6%89%A7%E8%A1%8C%E6%9F%A5%E8%AF%A2%E7%9A%84%E8%AF%9D%EF%BC%8C%E5%AF%B9%E5%BA%94%E7%9A%84%E8%8C%83%E5%9B%B4%E5%8C%BA%E9%97%B4%E5%B0%B1%E6%98%AF(-%E2%88%9E%2C%20%2B%E2%88%9E)%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E9%9C%80%E8%A6%81**%E5%B0%86%E5%85%A8%E9%83%A8%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E7%9A%84%E8%AE%B0%E5%BD%95%E8%BF%9B%E8%A1%8C%E5%9B%9E%E8%A1%A8**%EF%BC%8C%E8%BF%99%E4%B8%AA%E4%BB%A3%E4%BB%B7%E8%82%AF%E5%AE%9A%E6%AF%94%E7%9B%B4%E6%8E%A5%E5%85%A8%E8%A1%A8%E6%89%AB%E6%8F%8F%E9%83%BD%E5%A4%A7%E4%BA%86%E3%80%82%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%AF%B4**%E4%B8%80%E4%B8%AA%E4%BD%BF%E7%94%A8%E5%88%B0%E7%B4%A2%E5%BC%95%E7%9A%84%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E5%92%8C%E6%B2%A1%E6%9C%89%E4%BD%BF%E7%94%A8%E8%AF%A5%E7%B4%A2%E5%BC%95%E7%9A%84%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E4%BD%BF%E7%94%A8OR%E8%BF%9E%E6%8E%A5%E8%B5%B7%E6%9D%A5%E5%90%8E%E6%98%AF%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%E8%AF%A5%E7%B4%A2%E5%BC%95%E7%9A%84%E3%80%82**%0A%0A%23%23%23%23%203-3%20%E5%A4%8D%E6%9D%82%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E4%B8%8B%E6%89%BE%E5%87%BA%E8%8C%83%E5%9B%B4%E5%8C%B9%E9%85%8D%E7%9A%84%E5%8C%BA%E9%97%B4%0A%E6%AF%94%E5%A6%82%EF%BC%9A%0A!%5B31b71377de9ddebc52c1a3ee773afbbb.png%5D(en-resource%3A%2F%2Fdatabase%2F752%3A1)%0A%0A*%20%E9%A6%96%E5%85%88%E6%9F%A5%E7%9C%8B**WHERE%E5%AD%90%E5%8F%A5**%E4%B8%AD%E7%9A%84%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E9%83%BD%E6%B6%89%E5%8F%8A%E5%88%B0%E4%BA%86%E5%93%AA%E4%BA%9B%E5%88%97%EF%BC%8C**%E5%93%AA%E4%BA%9B%E5%88%97%E5%8F%AF%E8%83%BD%E4%BD%BF%E7%94%A8%E5%88%B0%E7%B4%A2%E5%BC%95**%0A%E8%BF%99%E4%B8%AA%E6%9F%A5%E8%AF%A2%E7%9A%84%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E6%B6%89%E5%8F%8A%E5%88%B0%E4%BA%86key1%E3%80%81key2%E3%80%81common_field%E8%BF%993%E4%B8%AA%E5%88%97%EF%BC%8C%E7%84%B6%E5%90%8Ekey1%E5%88%97%E6%9C%89%E6%99%AE%E9%80%9A%E7%9A%84%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95idx_key1%EF%BC%8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4%BD%93%E7%9A%84%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E7%AE%97%E6%B3%95%E6%9C%89%E4%BB%A5%E4%B8%8B%E4%B8%89%E7%A7%8D%EF%BC%9A%0A%0A%23%23%23%23%20Intersection%E5%90%88%E5%B9%B6%EF%BC%88%E4%BA%A4%E9%9B%86%E5%90%88%E5%B9%B6%EF%BC%89%0A%0AIntersection%E7%BF%BB%E8%AF%91%E8%BF%87%E6%9D%A5%E7%9A%84%E6%84%8F%E6%80%9D%E6%98%AF%E4%BA%A4%E9%9B%86%E3%80%82%E8%BF%99%E9%87%8C%E6%98%AF%E8%AF%B4%E6%9F%90%E4%B8%AA%E6%9F%A5%E8%AF%A2%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E5%A4%9A%E4%B8%AA%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%EF%BC%8C%E5%B0%86%E4%BB%8E%E5%A4%9A%E4%B8%AA%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E4%B8%AD%E6%9F%A5%E8%AF%A2%E5%88%B0%E7%9A%84%E7%BB%93%E6%9E%9C%E5%8F%96%E4%BA%A4%E9%9B%86%EF%BC%8C%E6%AF%94%E6%96%B9%E8%AF%B4%E4%B8%8B%E8%BE%B9%E8%BF%99%E4%B8%AA%E6%9F%A5%E8%AF%A2%EF%BC%9A%0A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key1%20%3D%20'a'%20AND%20key3%20%3D%20'b'%EF%BC%9B%0A%0A%E5%81%87%E8%AE%BE%E8%BF%99%E4%B8%AA%E6%9F%A5%E8%AF%A2%E4%BD%BF%E7%94%A8Intersection%E5%90%88%E5%B9%B6%E7%9A%84%E6%96%B9%E5%BC%8F%E6%89%A7%E8%A1%8C%E7%9A%84%E8%AF%9D%EF%BC%8C%E9%82%A3%E8%BF%99%E4%B8%AA%E8%BF%87%E7%A8%8B%E5%B0%B1%E6%98%AF%E8%BF%99%E6%A0%B7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9B%86%E6%AF%94%E5%8F%AA%E8%AF%BB%E5%8F%96%E4%B8%80%E4%B8%AA%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E7%9A%84%E6%88%90%E6%9C%AC%E6%9B%B4%E4%BD%8E%E3%80%82%0A%0A**MySQL%E5%9C%A8%E6%9F%90%E4%BA%9B%E7%89%B9%E5%AE%9A%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%E6%89%8D%E5%8F%AF%E8%83%BD%E4%BC%9A%E4%BD%BF%E7%94%A8%E5%88%B0Intersection%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%EF%BC%9A**%0A%0A**%E6%83%85%E5%86%B5%E4%B8%80**%EF%BC%9A**%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E5%88%97%E6%98%AF%E7%AD%89%E5%80%BC%E5%8C%B9%E9%85%8D%E7%9A%84%E6%83%85%E5%86%B5**%EF%BC%8C%E5%AF%B9%E4%BA%8E%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E6%9D%A5%E8%AF%B4%EF%BC%8C%E5%9C%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%B8%AD%E7%9A%84%E6%AF%8F%E4%B8%AA%E5%88%97%E9%83%BD%E5%BF%85%E9%A1%BB%E7%AD%89%E5%80%BC%E5%8C%B9%E9%85%8D%EF%BC%8C%E4%B8%8D%E8%83%BD%E5%87%BA%E7%8E%B0%E5%8F%AA%E5%87%BA%E7%8E%B0%E5%8C%B9%E9%85%8D%E9%83%A8%E5%88%86%E5%88%97%E7%9A%84%E6%83%85%E5%86%B5%E3%80%82!%5Bb54ee7dd61825fd7cc1c09ad8001d50f.png%5D(en-resource%3A%2F%2Fdatabase%2F756%3A0)%0A%0A**%E6%83%85%E5%86%B5%E4%BA%8C**%EF%BC%9A**%E4%B8%BB%E9%94%AE%E5%88%97%E5%8F%AF%E4%BB%A5%E6%98%AF%E8%8C%83%E5%9B%B4%E5%8C%B9%E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4%A2%E5%BC%95%E4%B9%8B%E9%97%B4%E5%8F%AF%E4%BB%A5%E9%87%87%E7%94%A8Intersection%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%EF%BC%8C%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E4%B9%9F%E5%8F%AF%E4%BB%A5%E6%9C%89%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E5%8F%82%E5%8A%A0%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E6%88%91%E4%BB%AC%E4%B8%8A%E8%BE%B9%E5%86%99%E7%9A%84%E6%83%85%E5%86%B5%E4%BA%8C%EF%BC%9A%E5%9C%A8%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E4%B8%AD%E6%9C%89%E4%B8%BB%E9%94%AE%E7%9A%84%E8%8C%83%E5%9B%B4%E5%8C%B9%E9%85%8D%E7%9A%84%E6%83%85%E5%86%B5%E4%B8%8B%E4%B9%9F%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8Intersection%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E3%80%82%E4%B8%BA%E5%95%A5%E4%B8%BB%E9%94%AE%E8%BF%99%E5%B0%B1%E5%8F%AF%E4%BB%A5%E8%8C%83%E5%9B%B4%E5%8C%B9%E9%85%8D%E4%BA%86%EF%BC%9F%E8%BF%98%E6%98%AF%E5%BE%97%E5%9B%9E%E5%88%B0%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF%E9%87%8C%EF%BC%8C%E6%AF%94%E5%A6%82%E7%9C%8B%E4%B8%8B%E8%BE%B9%E8%BF%99%E4%B8%AA%E6%9F%A5%E8%AF%A2%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key1%20%3D%20'a'%20AND%20id%20%3E%20100%EF%BC%9B%0A%0A%E5%81%87%E8%AE%BE%E8%BF%99%E4%B8%AA%E6%9F%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80%82%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%AF%B4%E5%8D%B3%E4%BD%BF%E6%83%85%E5%86%B5%E4%B8%80%E3%80%81%E6%83%85%E5%86%B5%E4%BA%8C%E6%88%90%E7%AB%8B%EF%BC%8C%E4%B9%9F%E4%B8%8D%E4%B8%80%E5%AE%9A%E5%8F%91%E7%94%9FIntersection%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%EF%BC%8C%E8%BF%99%E5%BE%97%E7%9C%8B%E4%BC%98%E5%8C%96%E5%99%A8%E7%9A%84%E5%BF%83%E6%83%85%E3%80%82%E4%BC%98%E5%8C%96%E5%99%A8%E5%8F%AA%E6%9C%89%E5%9C%A8%E5%8D%95%E7%8B%AC%E6%A0%B9%E6%8D%AE%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E4%BB%8E%E6%9F%90%E4%B8%AA%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E4%B8%AD%E8%8E%B7%E5%8F%96%E7%9A%84%E8%AE%B0%E5%BD%95%E6%95%B0%E5%A4%AA%E5%A4%9A%EF%BC%8C%E5%AF%BC%E8%87%B4%E5%9B%9E%E8%A1%A8%E5%BC%80%E9%94%80%E5%A4%AA%E5%A4%A7%EF%BC%8C%E8%80%8C%E9%80%9A%E8%BF%87Intersection%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E5%90%8E%E9%9C%80%E8%A6%81%E5%9B%9E%E8%A1%A8%E7%9A%84%E8%AE%B0%E5%BD%95%E6%95%B0%E5%A4%A7%E5%A4%A7%E5%87%8F%E5%B0%91%E6%97%B6%E6%89%8D%E4%BC%9A%E4%BD%BF%E7%94%A8Intersection%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E3%80%82%0A%0A%23%23%23%23%20Union%E5%90%88%E5%B9%B6%0A%0AIntersection%E6%98%AF%E4%BA%A4%E9%9B%86%E7%9A%84%E6%84%8F%E6%80%9D%EF%BC%8C%E8%BF%99%E9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C%95%E4%B8%AD%E7%9A%84%E6%AF%8F%E4%B8%AA%E5%88%97%E9%83%BD%E5%BF%85%E9%A1%BB%E7%AD%89%E5%80%BC%E5%8C%B9%E9%85%8D%EF%BC%8C%E4%B8%8D%E8%83%BD%E5%87%BA%E7%8E%B0%E5%8F%AA%E5%87%BA%E7%8E%B0%E5%8C%B9%E9%85%8D%E9%83%A8%E5%88%86%E5%88%97%E7%9A%84%E6%83%85%E5%86%B5%E3%80%82**%0A**%E6%83%85%E5%86%B5%E4%BA%8C**%EF%BC%9A**%E4%B8%BB%E9%94%AE%E5%88%97%E5%8F%AF%E4%BB%A5%E6%98%AF%E8%8C%83%E5%9B%B4%E5%8C%B9%E9%85%8D%E3%80%82**%0A**%E6%83%85%E5%86%B5%E4%B8%89**%EF%BC%9A**%E4%BD%BF%E7%94%A8Intersection%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E7%9A%84%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E3%80%82**%0A%E8%BF%99%E7%A7%8D%E6%83%85%E5%86%B5%E5%85%B6%E5%AE%9E%E4%B9%9F%E6%8C%BA%E5%A5%BD%E7%90%86%E8%A7%A3%EF%BC%8C%E5%B0%B1%E6%98%AF%E6%90%9C%E7%B4%A2%E6%9D%A1%E4%BB%B6%E7%9A%84%E6%9F%90%E4%BA%9B%E9%83%A8%E5%88%86%E4%BD%BF%E7%94%A8Intersection%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E7%9A%84%E6%96%B9%E5%BC%8F%E5%BE%97%E5%88%B0%E7%9A%84%E4%B8%BB%E9%94%AE%E9%9B%86%E5%90%88%E5%92%8C%E5%85%B6%E4%BB%96%E6%96%B9%E5%BC%8F%E5%BE%97%E5%88%B0%E7%9A%84%E4%B8%BB%E9%94%AE%E9%9B%86%E5%90%88%E5%8F%96%E4%BA%A4%E9%9B%86%EF%BC%8C%E6%AF%94%E6%96%B9%E8%AF%B4%E8%BF%99%E4%B8%AA%E6%9F%A5%E8%AF%A2%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key_part1%20%3D%20'a'%20AND%20key_part2%20%3D%20'b'%20AND%20key_part3%20%3D%20'c'%20OR%20(key1%20%3D%20'a'%20AND%20key3%20%3D%20'b')%EF%BC%9B%0A%0A%23%23%23%23%20Sort-Union%E5%90%88%E5%B9%B6%0A%0AUnion%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E7%9A%84%E4%BD%BF%E7%94%A8%E6%9D%A1%E4%BB%B6%E5%A4%AA%E8%8B%9B%E5%88%BB%EF%BC%8C%E5%BF%85%E9%A1%BB%E4%BF%9D%E8%AF%81%E5%90%84%E4%B8%AA%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E5%88%97%E5%9C%A8%E8%BF%9B%E8%A1%8C%E7%AD%89%E5%80%BC%E5%8C%B9%E9%85%8D%E7%9A%84%E6%9D%A1%E4%BB%B6%E4%B8%8B%E6%89%8D%E5%8F%AF%E8%83%BD%E8%A2%AB%E7%94%A8%E5%88%B0%EF%BC%8C%E6%AF%94%E6%96%B9%E8%AF%B4%E4%B8%8B%E8%BE%B9%E8%BF%99%E4%B8%AA%E6%9F%A5%E8%AF%A2%E5%B0%B1%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%E5%88%B0Union%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%EF%BC%9A%0ASELECT%20*%20FROM%20single_table%20WHERE%20key1%20%3C%20'a'%20OR%20key3%20%3E%20'z'%EF%BC%9B%0A%0A%E8%BF%99%E6%98%AF%E5%9B%A0%E4%B8%BA%E6%A0%B9%E6%8D%AEkey1%20%3C%20'a'%E4%BB%8Eidx_key1%E7%B4%A2%E5%BC%95%E4%B8%AD%E8%8E%B7%E5%8F%96%E7%9A%84%E4%BA%8C%E7%BA%A7%E7%B4%A2%E5%BC%95%E8%AE%B0%E5%BD%95%E7%9A%84%E4%B8%BB%E9%94%AE%E5%80%BC%E4%B8%8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C%E8%83%BD%E7%94%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E6%9C%80%E5%A5%BD%E7%94%A8%E8%81%94%E5%90%88%E7%B4%A2%E5%BC%95%E4%BB%A3%E6%9B%BF%E7%B4%A2%E5%BC%95%E5%90%88%E5%B9%B6%E3%80%82**%0A%0A%0A%0A</center></span>
</div></body></html> 